package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"ytdownloader-api/config"
	"ytdownloader-api/controller"
)

func main() {
	if err := config.InitConfig(); err != nil {
		panic(err)
	}
	//
	if err := config.InitDB(); err != nil {
		panic(err)
	}

	app := gin.Default()
	app.GET("/api/v1/videos", controller.GetAllVideos)
	app.GET("/api/v1/parse", controller.ParseUrl)
	app.POST("/api/v1/videos", controller.CreateVideo)
	app.PUT("/api/v1/videos/:id", controller.UpdateVideo)
	app.DELETE("/api/v1/videos/:id", controller.DeleteVideo)
	port := config.GetConfig().App.Port
	err := app.Run(fmt.Sprint(":", port))
	if err != nil {
		panic(err)
	}
}
